home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / commio0b.zip / COMMIO.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-20  |  56KB  |  1,560 lines

  1. {$X+,A+,V-,R-,S-,O-,B-}
  2. unit commio;
  3. {
  4.                  This is the Main Communications unit (COMMIO)
  5.        Written by Jason Morriss aka. Lief O'Pardy;  (started on 7/26/95)
  6.  
  7.                    Copyright (C) 1995,1996 by Jason Morriss
  8.  
  9.   Some real documentation will be written at a later date, for now you'll
  10.   just have to look at the procedure/function headers to see what each
  11.   routine does.
  12.   I will try to describe how to use these routines to setup any type of door
  13.   program for use on a BBS (a better description will be given when the DOC's
  14.   are written):
  15.  
  16.   1)  Get any and all information that you need about the USER and BBS when
  17.       your door starts.  You need this information so you can setup the USER
  18.       and BBS variables.  For instance, You need to know if the user is using
  19.       ANSI or not, what node s/he is on, etc...  As for the BBS (this is most
  20.       important, without this step your door will probably not work at all
  21.       and will probably freeze the BBS), you need to find out what Comport
  22.       and the Baudrate the user is connected at, without this you cannot
  23.       communicate with the user at the remote end.
  24.       Either use a DROPFILE (the routines for this are not completed yet),
  25.       The command line, or an INI file...
  26.       Bare minimum get the Comport, Baudate, WhichIO (fossil, internal) and
  27.       MaxTimeAllowed!
  28.   2)  Once all the important info has been put into the "DOOR" record (look
  29.       below for the door record), Make a call to the InitComport function.
  30.       If that function returns true then all is alright and you can continue,
  31.       otherwise you should halt the door so the BBS can take control again.
  32.       Then call InstallAllTasks so that the Timing variables will be setup,
  33.       and then you can forget about them.  The user will be automatically
  34.       booted out if his/her time runs out.  You can also optionally call
  35.       ShowStatusBar.  This procedure displays a Statusbar at the bottom of
  36.       the screen.  With info on the user, connection, local env., and time
  37.       remaining (Pressing F2 while in the DOOR will show the status line too).
  38.   3)  You should now be able to do anything you want with your door.  enjoy.
  39.   4)  Most door libraries require you to call a certain procedure to DE-Init
  40.       the comport, etc...  You dont have to do a thing with this library!
  41.       Just let your program exit normally.  Look in the "_EXIT" unit for more
  42.       details.  Its all done automatically, it wont hurt if you do call the
  43.       Deinitcomport() though...
  44.  
  45. }
  46. interface
  47.  
  48. uses _exit, crt, dos, async, fosunit, mtask;
  49.  
  50.  
  51. type
  52.   Tscreen    = array[0..24,0..159] of byte;
  53.   TSystemEnv = (NoTasker{,DOS5},DDOS,DV,WIN,OS2,NetWare);
  54.   TWhichIO   = ({LocalIO,}FossilIO,InternalIO);
  55.   TCharAry   = array[0..0] of char;
  56.   string40   = string[40];
  57.   string12   = string[12];
  58.  
  59. {v- anything with an (R) in front of it, is READ ONLY; do not write to them
  60.     in your own door code.}
  61.   Tdoor = record (* Record for the more common "DOOR-System" variables *)
  62.     UserName    : string[40];{user's name; could be alias or real}
  63.     {------------------------}
  64.     ComPort     : byte;      {Which Comport the program is using; 0=local}
  65.     Baudrate    : longint;   {Baudrate for the comport}
  66.     WhichIO     : TWhichIO;  {Which IO routines to use; fossil or internal}
  67.     IOinstalled : boolean;   {comport IO routines installed?}
  68.     InBufSize   : word;      {Input buf size. (only for internal routines)}
  69.     OutBufSize  : word;      {Output buf size. (only for internal routines)}
  70.     IRQ         : byte;      {Which IRQ is being used}
  71.     WordSize    : byte;      {Wordsize (databits) for comport}
  72.     Parity      : char;      {parity for comport; 'N'=none 'E'=even 'O'=odd}
  73.     StopBits    : byte;      {stopbits for comport}
  74.     node        : byte;      {Which node the user is on (on BBS)}
  75.     {------------------------}
  76.     UseAnsi     : boolean;   {Is ansi used or not?}
  77.     {^ Even if in local mode, this must be true in order to use commands
  78.        that would use ANSI to the remote user. }
  79.     UseColor    : boolean;   {Is color used or not?}
  80.     UseAni      : boolean;   {Is animation used or not? (see putstr in doorio)}
  81.     SmartColor  : boolean;   {"Smart" mode ON/OFF for ansi color code sending}
  82.     LocalInputON: boolean;   {Enable/Disable local keyboard input}
  83.     UpdateLocal : boolean;   {Writes to the local screen are allowed or not?}
  84. {R} UpdateStatusBar:boolean; {update status bar? (even if updatelocal=false)}
  85. {R} UseVirtScr  : boolean;   {Use the virtual screen?}
  86.     StatusBarY  : byte;      {What line the status bar is displayed on}
  87.     LocalMaxY   : byte;      {# of lines (1-#) to update on local screen (usually 25)}
  88.     {------------------------}
  89. {R} CurTime     : DateTime;  {Current Time. Updated consistently; 24h format}
  90.     SecsLeft    : longint;   {Seconds left until user is booted back to BBS}
  91. {R} SecsOn      : longint;   {how long the user has been in the door}
  92.     KickOffIdle : integer;
  93.     {^# of secs the user can be idle before he gets booted back to the bbs.
  94.       This will "beep" the user once when the Idle Time is <= 30 seconds.
  95.       A value of -1 will disable the Auto-KickOff feature.  (this variable
  96.       does not get decremented "CurIdle" does).}
  97. {R} LocalKey    : boolean;   {Was the last key pressed local?}
  98.     OnLine      : boolean;   {Is user online/connected?}
  99.     PauseLine   : byte;      {# of lines to display before pausing output; 24=default}
  100.     {^ will probably be taken out.}
  101.     CurLine     : byte;      {Current line counter}
  102.     {^ will probably be taken out; use "virty" instead.}
  103.     {------------------------}
  104.   end;
  105.  
  106. const
  107.   CurIdle : integer = 0;              {Idle counter for auto-kickoff feature}
  108.   IdleStart : longint = 0;
  109.   MaxTimeAllowed : word = 24*60;   {Maximum time allowed in DOOR; in MINUTES}
  110.   {^ 2*60 = 2 hours.}
  111.  
  112. var
  113.   MacroStr    : string;              { Macro string; used in readkey funcs. }
  114.   door        : tdoor;               { "door-system" variables }
  115.   StartTime   : datetime;            { when user entered door }
  116.   SystemEnv   : tsystemenv;          { What OS is operating locally? }
  117.   KickedOut   : boolean;             { was user kicked out? (F6) }
  118.   Beeped      : boolean;
  119.  
  120. const {virtual screen variables}
  121.   VirtScr : ^tscreen = nil;          { Virtual Screen }
  122.   VirtX   : integer = 1;             { Virtual X screen position for cursor }
  123.   VirtY   : integer = 1;             { Virtual Y screen position for cursor }
  124.   {^ even if the virtual screen is not initialized, the VirtX/Y variables are
  125.      used to determine where the cursor is.
  126.      Anytime you want to know where the cursor is, use these variables.  Do
  127.      NOT use WhereX/Y... sometimes you'll get the wrong result.}
  128.  
  129. var
  130.   SkipReadkey : boolean;
  131.   {^ special variable. if true, and the sysop pushes a syskey then; the
  132.      sioreadkey function will call the syskey function and then exit the
  133.      sioreadkey function itself, returning a nul (#0) char, then continuing
  134.      with the program.  Its hard to explain.  I needed this for the file
  135.      displaying file routines.  you will never have to mess or even look at
  136.      this variable while programming (unless you really, really want too ;)}
  137.  
  138. {─--[headers]-──────────────────────────────────────────────────────────────}
  139. Function InitComport:boolean;
  140. {^ Initializes the comport for IO. This is normally the 2nd thing that is
  141.    called when your door starts (the 1st thing would either be reading a
  142.    DropFile, or INI file, or both).  This must be called before any of the
  143.    other comport IO routines are called! (any procs. that use the modem).  No
  144.    params are needed... because all the values needed are taken from the
  145.    "door" record (port,baud,parity), So the DOOR var must be setup first. }
  146. Procedure DeInitComport;
  147. {^ DeInitializes the comport.  You can call this at the end of your door, but
  148.    you don't have to.  It will be called automatically on its own at the end
  149.    of the program, its better if you don't call it.
  150.    (see also: AddToExi